discoveryengine: add pre-delete hook to detach stores on destroy#17273
discoveryengine: add pre-delete hook to detach stores on destroy#17273btkelly wants to merge 4 commits intoGoogleCloudPlatform:mainfrom
Conversation
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @melinath, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
Non-exercised tests🔴 Tests were added that are skipped in VCR:
Tests analyticsTotal tests: 41 Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
| collection_id: 'collection-id' | ||
|
|
||
| virtual_fields: | ||
| - name: 'detach_stores_on_destroy' |
There was a problem hiding this comment.
This seems like it could be a good candidate for a deletion_policy field that has a FORCE option (which would trigger detaching stores). What would you think about that? Some more information on deletion policy fields at https://googlecloudplatform.github.io/magic-modules/best-practices/deletion-behaviors/ (though it's a bit sparse... basically it's a virtual field like you have, but it takes an enum rather than a bool.)
There was a problem hiding this comment.
This works for me, I'd rather follow existing patterns. This was a pattern inside the Dialog Flow modules but it looks like a one off. I'll update this to be an enum with "DEFAULT" which does nothing additional and "FORCE" to detach the stores.
There was a problem hiding this comment.
I've updated the pattern to follow the deletion policy format, take a look when you get a second and let me know if that works for you.
This PR updates the google_discovery_engine_data_connector resource to use the standard Google provider pattern for deletion behavior by introducing the deletion_policy field.
It adds a custom pre_delete hook that detaches associated Data Stores from Search Engines before deleting the Data Connector when deletion_policy = "FORCE", preventing circular dependency/destruction order errors and leaving the resource clean.
An acceptance test was added (TestAccDiscoveryEngineDataConnector_deletionPolicyForce) using the Jira data source (avoiding the complex IdP setup requirements needed for ServiceNow).
Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.